﻿using Contract.Read_WebApi.Application.Commands;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Contract.Read_WebApi.Controllers
{
    /// <summary>
    /// 显示模块
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReadContractController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public ReadContractController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 显示货主合同列表
        /// </summary>
        /// <param name="listContractCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> ListHZContractAsync([FromQuery] ListHZContractCommand listContractCommand)
        {
            return Ok(await mediator.Send(listContractCommand));
        }

        /// <summary>
        /// 显示承运合同列表
        /// </summary>
        /// <param name="listCYContractCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> ListCYContractAsync([FromQuery] ListCYContractCommand listCYContractCommand)
        {
            return Ok(await mediator.Send(listCYContractCommand));
        }

        /// <summary>
        /// 显示通用合同列表
        /// </summary>
        /// <param name="listTYContractCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> ListTYContractAsync([FromQuery] ListTYContractCommand listTYContractCommand)
        {
            return Ok(await mediator.Send(listTYContractCommand));
        }

        /// <summary>
        /// 显示通用合同详情
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> InfoTYContractAsync([FromQuery]InfoTYContractCommand info)
        {
            return Ok(await mediator.Send(info));
        }

        /// <summary>
        /// 显示货主合同详情
        /// </summary>
        /// <param name="infoHZContractCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> InfoHZContractAsync([FromQuery]InfoHZContractCommand infoHZContractCommand)
        {
            return Ok(await mediator.Send(infoHZContractCommand));
        }

        /// <summary>
        /// 显示承运合同详情
        /// </summary>
        /// <param name="infoCYContractCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> InfoCYContractAsync([FromQuery] InfoCYContractCommand infoCYContractCommand)
        {
            return Ok(await mediator.Send(infoCYContractCommand));
        }

        /// <summary>
        /// 审批货主合同
        /// </summary>
        /// <param name="submitListHZContractCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> SubmitListHZContract([FromQuery]SubmitListHZContractCommands submitListHZContractCommands)
        {
            return Ok(await mediator.Send(submitListHZContractCommands));
        }

        /// <summary>
        /// 审批承运合同
        /// </summary>
        /// <param name="submitListCYContractCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> SubmitListCYContract([FromQuery] SubmitListCYContractCommands submitListCYContractCommands)
        {
            return Ok(await mediator.Send(submitListCYContractCommands));
        }

        /// <summary>
        /// 审批通用合同
        /// </summary>
        /// <param name="submitListTYContractCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> SubmitListTYContract([FromQuery]SubmitListTYContractCommands submitListTYContractCommands)
        {
            return Ok(await mediator.Send(submitListTYContractCommands));
        }

        /// <summary>
        /// 获取地址经纬度
        /// </summary>
        /// <param name="getCoordinatesCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetCoordinatesAsync([FromQuery]GetCoordinatesCommands getCoordinatesCommands)
        {
            return Ok(await mediator.Send(getCoordinatesCommands));
        }

        /// <summary>
        /// 根据编号获得反填
        /// </summary>
        /// <param name="infoContractCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> InfoContractAsync([FromQuery] InfoContractCommands infoContractCommands)
        {
            return Ok(await mediator.Send(infoContractCommands));
        }
    }
}
